﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UCUserManager.ascx.cs"
    Inherits="AIC_CD.UCUserManager" %>

<script type="text/javascript">
    function CheckAll(obj, itemChkID) {

        for (var i = 0; i < obj.form.elements.length; i++) {
            if (obj.form.elements[i].name.indexOf(itemChkID) != -1 && obj.form.elements[i].type == 'checkbox' && obj.form.elements[i].name != obj.name) {
                if (obj.checked) {
                    obj.form.elements[i].checked = true;
                }
                else {
                    obj.form.elements[i].checked = false;
                }
            }
        }
    }

    function CheckXem(obj, nameobj) {
        var item = obj.id;
        var unitem = item.replace(nameobj, "chkXem");
        if (obj.checked) {
            document.getElementById(unitem).checked = true;
        }
    }
</script>

<div id="Div1" class="FormTitle" runat="server">
    <p class="TextTitle">
        Quản trị người dùng
        <asp:ImageButton CssClass="btnExit" ID="ImageButton1" runat="server" ImageUrl="Images/exit.png"
            Height="24px" OnClick="ImageButton1_Click" />
    </p>
</div>
<div class="FormMain">
    <table>
        <tr>
            <td style="width: 30%" valign="top" align="left">
                <div class="Form Tree">
                    <asp:DataList ID="dtlNhomNguoiDung" runat="server" DataKeyField="ID" OnItemCommand="dtlNhomNguoiDung_ItemCommand"
                        BackColor="White" BorderColor="#FFF" BorderWidth="0" CellPadding="4" ForeColor="Black"
                        GridLines="Vertical" Width="300px" CssClass="ListTable">
                        <FooterStyle BackColor="#CCCC99" />
                        <AlternatingItemStyle BackColor="White" />
                        <ItemStyle BackColor="#F7F7DE" />
                        <SelectedItemStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
                        <HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
                        <ItemTemplate>
                            <asp:LinkButton ID="lbtNhomNguoiDung" runat="server" Text='<%#Eval("TenDM") %>'></asp:LinkButton>
                        </ItemTemplate>
                    </asp:DataList>
                </div>
            </td>
            <td style="width: 100%">
                <div class="Form View">
                    <asp:GridView ID="grdDanhMuc" runat="server" AutoGenerateColumns="False" CssClass="ListTable">
                        <Columns>
                            <asp:TemplateField HeaderText="Danh sách quyền người dùng">
                                <ItemTemplate>
                                    <asp:Label ID="lblID" runat="server" Visible="false" Text='<%# Eval("ID") %>'></asp:Label>
                                    <asp:Label ID="lblIDDM" runat="server" Text='<%# Eval("TenDM") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Xem">
                                <HeaderTemplate>
                                    Xem<br />
                                    <input id="Checkbox1" type="checkbox" onclick="javascript:CheckAll(this,'chkXem');" />
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <asp:CheckBox ID="chkXem" runat="server" Checked='<%# Eval("Xem").ToString().Equals("1")%>' />
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Tạo mới">
                                <HeaderTemplate>
                                    Tạo mới<br />
                                    <input id="Checkbox2" type="checkbox" onclick="javascript:CheckAll(this,'chkTaoMoi');" />
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <asp:CheckBox ID="chkTaoMoi" runat="server" OnClick="javascript:CheckXem(this,'chkTaoMoi')"
                                        Checked='<%# Eval("Them").ToString().Equals("1") %>' />
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Cập nhật">
                                <HeaderTemplate>
                                    Cập nhật<br />
                                    <input id="Checkbox3" type="checkbox" onclick="javascript:CheckAll(this,'chkCapNhat');" />
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <asp:CheckBox ID="chkCapNhat" runat="server" OnClick="javascript:CheckXem(this,'chkCapNhat')"
                                        Checked='<%# Eval("Sua").ToString().Equals("1") %>' />
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Xóa">
                                <HeaderTemplate>
                                    Xóa<br />
                                    <input id="Checkbox4" type="checkbox" onclick="javascript:CheckAll(this,'chkXoa');" />
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <asp:CheckBox ID="chkXoa" runat="server" OnClick="javascript:CheckXem(this,'chkXoa')"
                                        Checked='<%# Eval("Xoa").ToString().Equals("1") %>' />
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Ghi chú">
                                <ItemTemplate>
                                    <asp:TextBox ID="txtGhiChu" Text='<%# Eval("GhiChu") %>' TextMode="MultiLine" Width="380px"
                                        runat="server"></asp:TextBox>
                                </ItemTemplate>
                                <ItemStyle Width="400px" />
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                    <asp:Button ID="btnThem" runat="server" Text="Lưu quyền người dùng" CssClass="cmdBtn"
                        OnClick="btnThem_Click" Visible="False" />
                </div>
            </td>
        </tr>
    </table>
</div>
